package com.meilele.controller.czh;

import com.meilele.biz.czh.FiveCommentariesBiz;
import com.meilele.entity.czh.FiveCommentaries;
import com.meilele.entity.shiro.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Date;

@Controller
@RequestMapping("/fiveComm")
public class FIveCommentariesController {
    @Resource
    private FiveCommentariesBiz fiveCommentariesBiz;
    @RequestMapping("/add")
    public void add( String commentariesContent,int postId,HttpSession session){
        User user=(User) session.getAttribute("user");
        Date now = new Date();
        FiveCommentaries fiveCommentaries=new FiveCommentaries();
        fiveCommentaries.setCommentariesName(user.getUsername());
        fiveCommentaries.setCommentariesTime(now);
        fiveCommentaries.setCommentariesContent(commentariesContent);
        fiveCommentaries.setPostId(postId);
        fiveCommentariesBiz.save(fiveCommentaries);
    }
}
